<template>
  <div class="theme">
    <!-- 特价酒店 -->
    <el-tabs v-model="activeName" @tab-click="handleClick" v-if="path">
      <el-tab-pane :label="item.aid" :name="item.aid" v-for="item in sptitle" :key="item.id"></el-tab-pane>
    </el-tabs>
    <el-row class="imglist">
      <el-col :span="6" v-for="item in hotelList" :key="item.id">
        <img :src="item.image" alt>
        <div class="imgmb"   @click="goto(item.id)">
          <div class="htitle">
            <h4>{{item.num}}</h4>
            <p class="ptitle">
              <span>{{item.title}}</span>
              <br>
              <span>{{item.lable}}</span>
            </p>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "themehotel",

  data() {
    return {
      activeName: "西安",
      hotelList: [],
      sptitle: [],
      path: true,
      path1: ""
    };
  },

  mounted() {
    this.handleClick({ label: "西安" });
    this.$http.get("/hotelSpeciaTitle").then(res => {
      // console.log(res.data)
      this.sptitle = res.data.data;
    });
    this.path1 = this.$route.path.split("/")[1];
    if (this.path1 == "detailHotel") {
      this.path = false;
    }
  },
  components: {},

  methods: {
    goto(id){
      // console.log(id)
      this.$router.push("/detailHotel/"+id)
    },
    // 特价酒店列表
    handleClick(tab) {
      // console.log("--", tab.label);
      this.$http
        .post("/hotelHomerecom", {
          aid: tab.label
        })
        .then(res => {
          this.hotelList = res.data.data;
          // console.log("aaa",this.hotelList )
        })
        .catch(err => {
          console.log(err);
        });
    }
  }
};
</script>

<style lang="scss" scoped>
/deep/ .el-tabs__item {
  font-size: 18px;
  padding: 10px 40px;
  height: 50px;
  width: 190px;
  text-align: center;
}
/deep/ .el-tabs__active-bar {
  width: 190px;
}
.imglist {
  img {
    width: 100%;
    box-shadow: 4px 10px 4px rgba(0, 0, 0, 0.4);
    border-radius: 5px;
  }
  /deep/ .el-col-6 {
    padding: 10px;
    position: relative;
  }
  .imgmb {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 280px;
    height: 207px;
    color: #fff;
    text-align: left;
    box-sizing: border-box;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    .htitle {
      h4 {
        width: 60px;
        text-align: center;
        padding: 5px;
        background: rgba(0, 0, 0, 0.4);
        border-radius: 8px;
      }
      .ptitle {
        position: absolute;
        bottom: 10px;
        left: 10px;
        >span:nth-child(1){
          color: #fff;
          font-weight: bold;
          font-size: 15px;

        }
        >span:nth-child(3){
          margin-top: 5px;
          font-size: 13px;
          display: block;
          width: 60px;
          white-space:nowrap;
          overflow:hidden;
          text-overflow:ellipsis;
        }
      }
    }
  }
}
</style>